<?php
/*
+---------------------------------------------------------------+
|        e107 website system
|        Easy Admin Page by Cameron. (www.e107coders.org)
|        a part of Your_plugin v3.1  multilanguage by Juan  Reseau.li
|        Released under the terms and conditions of the
|        GNU General Public License (http://gnu.org).
|		 Suitable only for e107 v0.7
+---------------------------------------------------------------+
*/

require_once("../../class2.php");
if(!getperms("P")){ header("location:".e_BASE."index.php"); exit; }
require_once(e_ADMIN."auth.php");

      $text = "";
     if(isset($_POST['submit'])) //if submit has been pushed to create a monster
     {

         $file=$_POST['file'];
require_once("cmsfiles/".$file);
	   $prefix=$_POST['prefix'];
	   $desc=$_POST['desc'];
	   $path=$_POST['path'];
	   $loginmode=$_POST['loginmode'];
	   $passmode=$_POST['passmode'];
       $checkname="SELECT * from e107_cipcms where path='$path'";
       $checkname2=mysql_query($checkname) or die("Could not query monsters");
       while($checkname3=mysql_fetch_array($checkname2))
       {
         $themonster=$checkname3[path];
       }
       if($themonster) 
       {
         $text .= "Sorry, you have already used the cms importation with $path";
       }
       else if($passmode=='')
{
$text .= "Please choose a type of password change!";
}
else
       {
$sql = "INSERT INTO `e107_cipcms` (`file`, `loginmode`, `passmode`, `path`, `descr`, `cmsprefix`) VALUES ('$file', '$loginmode', '$passmode', '$path', '$desc','$prefix')";
        mysql_query($sql) or die("Could not create monster");
        $text .= "<h2>".$cmsname." integrated!</h2><br/>".$cmsii15;
       }
 

     }
     
     else
    {
$prefile=$_GET['cmsfile'];
require_once("cmsfiles/".$prefile);
       $text .= "<form action='admin_new2.php' method='post'>";
       $text .= "Welcome to the $cmsname $cmsvers Integration page. Please fill the fields:<br/>";
       $text .= "CMS File:<br/>";
       $text .= "<input class='tbox' type='text' name='file' size='15' value='".$prefile."'><br/>";
       $text .= "MySQL CMS DB Prefix:<br/>";
       $text .= "<input class='tbox' type='text' name='prefix' size='15' value='".$cmsdpre."'><br/>";
       $text .= "Name and/or Description:<br/>";
       $text .= "<input class='tbox' type='text' name='desc' size='15'><br/>";
       $text .= "CMS location: example: http://www.example.org/cms/<br/>";
       $text .= "<input class='tbox' type='text' name='path' size='15'><br/>";
if ($cmsfver=="1.5")
{

$text .= "<br/>Login mode:<br/>";
$text .= "	<input name='loginmode' value='redir' type='radio'> Redirection System (old)&nbsp;&nbsp;
	<input name='loginmode' value='auto' checked='checked' type='radio'> auto-click login button";
$text .= "<br/>When the $cmsname password is not the same of the e107 password:<br/>
<input name='passmode' value='message' type='radio'> Show a message to login or to do a password recovery (recomended for existing installations)<br/>
<input name='passmode' value='auto' type='radio'> Change the $cmsname password automatically.(recomended to new installations) ";
}
       $text .= "<br/><input class='button' type='submit' name='submit' value='Create CMS integration'>";
       $text .= "</form>";  

    }

$ns -> tablerender("e107Cip - Admin", $text);

require_once(e_ADMIN."footer.php");

?>
